<template>
  <svg :class="svgClass" aria-hidden="true" v-on="$attrs">
    <use :xlink:href="iconName" />
  </svg>
</template>
<script setup lang="ts" name="svgIcon">
import { defineProps, computed } from "vue";
let props = defineProps({
  iconClass: {
    type: [String],
    required: true,
  },
  className: {
    type: String,
    default: "",
  },
});

let iconName = computed(() => {
  return `#icon-${props.iconClass as string}`;
});

let svgClass = computed(() => {
  if (props.className) {
    return "svg-icon " + props.className;
  } else {
    return "svg-icon";
  }
});

// $forceUpdate就是 对$set和$delete增强

// this.arr[0]='你好'
// this.$forceUpdate();
</script>

<style scoped>
.svg-icon {
  width: 1em;
  height: 1em;
  margin-right: 6px;
  vertical-align: -0.15em;
  fill: currentColor;
  overflow: hidden;
}
</style>
